function [metabioliteKEGGID, cost]= get_kegg_id_by_metFormula(metFormula, treshhold)
    cost=0;
    costForFormulaFound = 5;
    costForEmptyID = 15;
    metabioliteKEGGID = '';

    if ~isempty(metFormula)
        url = strcat('http://rest.kegg.jp/find/compound/', metFormula, '/formula');
        returnData = urlread(url);
        returnDataLinesArray = strtrim(regexp(returnData, '\n', 'split'));
        returnDataLinesArray(cellfun(@isempty,returnDataLinesArray)) = [];
        if length(returnDataLinesArray) == 1
            metaboliteData = returnDataLinesArray{1,1};
            metaboliteKEGGID = metaboliteData(5:10);
        elseif length(returnDataLinesArray) > 1
            costArray = [];
            for i = 1:length(returnDataLinesArray)
                metaboliteNames = strtrim(returnDataLinesArray{i}(11:length(returnDataLinesArray{i})));
                costArray = [costArray, edit_distance_in_strings(upper(metFormula),upper(metaboliteNames))];
            end
            [c,ind_a] = intersect(costArray,min(costArray));

            if c < treshhold
                 metaboliteKEGGID = returnDataLinesArray{ind_a}(5:10); 
                 cost = c + costForFormulaFound;
            else
                cost = costForEmptyID;
                metaboliteKEGGID = '';
            end
        else
             cost = costForEmptyID;
             metaboliteKEGGID = '';
        end
    else
        cost = costForEmptyID;
    end
end

